package com.ihome.android.market2.asynctask;

import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.TextUtils;

import com.ihome.android.http.HttpActions;
import com.ihome.android.util.exception.ITVException;
import com.ihome.android.util.log.LogUtil;

/**
 * 应用升级结果上报
 * 
 * @author Emerson
 * 
 */
public class UpdateResultReportTask extends AsyncTask<String, Integer, Bundle> {
	private final String		TAG			= UpdateResultReportTask.class.getSimpleName();
	private Context				context;

	public UpdateResultReportTask(Context context) {
		this.context = context;
	}

	@Override
	protected void onPreExecute() {
		super.onPreExecute();
	}

	@Override
	protected Bundle doInBackground(String... params) {
		String appList = params[0];
		
		LogUtil.v(TAG, "appList = " + appList);
		if(TextUtils.isEmpty(appList)){
			return null;
		}
		
		Bundle b = new Bundle();
		try {
			String result = new HttpActions(context).reportMarketUpdateResult(appList);
			LogUtil.v(TAG, "result = " + result);
			if (!TextUtils.isEmpty(result)) {

			}
			else {
				cancel(true);
			}
		} catch (ITVException e) {
			e.printStackTrace();
			LogUtil.e(TAG, e.toString());
		}
		return b;
	}

	@Override
	protected void onPostExecute(Bundle result) {
		super.onPostExecute(result);
	}

	@Override
	protected void onCancelled() {
		super.onCancelled();
		LogUtil.i(TAG, "--> onCancelled");

	}

}
